/*
 * LocationActivity.java
 * business
 *
 * Created by SunDing on 2017/1/9.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.location;

import android.app.Activity;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * 首次打开app 定位选择
 */
public class LocationActivity extends BaseActivity {

    private LocationFragment locationFragment;

    /**
     * @param activity
     * @param isFromLogin 是否来自于登录界面  是的话显示返回按钮
     */
    public static void actionStart(Activity activity, boolean isFromLogin) {
        Intent intent = new Intent(activity, LocationActivity.class);
        intent.putExtra(Intents.IS_FROM_LOGIN, isFromLogin);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        locationFragment =
                (LocationFragment)
                        getSupportFragmentManager().findFragmentById(R.id.container_location);

        if (locationFragment == null) {
            locationFragment = LocationFragment.getInstance(getIntent().getExtras());
            ActivityUtils.addFragmentToActivity(
                    getSupportFragmentManager(), locationFragment, R.id.container_location);
        }
    }

    @Override
    protected void initPresenter() {
        new LocationPresenter(locationFragment);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_location;
    }
}
